import puly.arr.Manager;

public class MonsterTest1 {
    public static void main(String[] args) {
        Monster monster=new Monster("小妖怪","巡山",1000);
        System.out.println(monster.toString());
//        就会默认调用monster的toString()方法
        System.out.println(monster);
        Car4 car4=new Car4("baoma");
        car4=null;
//        主动调用垃圾回收器
        System.gc();
        System.out.println("程序退出了。。。");
    }


}

class Car4{
    private String name;
    public Car4(String name){
        this.name=name;
    }
//重写垃圾回收方法finalize()
    @Override
    protected void finalize() throws Throwable {
        System.out.println("正在销毁资源");
        super.finalize();
        System.out.println("资源已回收");
    }
}